/*
 * @Author: 老刘
 * @Date: 2020-04-29 15:51:38
 * @Description: 心跳
 */
Page({
	data: {
		animationForHeartbeat: ''
	},
	onLoad () {
		let circleCount = 0;
		const that = this;
		// 心跳的外框动画
		const animation = wx.createAnimation({
			duration: 500, // 以毫秒为单位
			timingFunction: 'linear',
			delay: 100,
			transformOrigin: '50% 50%'
		});
		// setTimeout 替换 setInterval 避免出现时间差
		setTimeout(function f () {
			if (circleCount % 2 === 0) {
				animation.scale(1.25).step();
			} else {
				animation.scale(1.0).step();
			}
			that.setData({
				animationForHeartbeat: animation.export()
			});
			circleCount++;
			if (circleCount === 500) {
				circleCount = 0;
			}
			setTimeout(f, 500);
		}, 500);
	}
});
